package com.chaodev.base.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

@Data
@ApiModel(description = "学习记录")
public class LearningRecordDto {

    @NotNull(message = "课程id不能为空")
    @ApiModelProperty("课程id")
    private Integer trainingId;

    @NotNull(message = "开始学习时间startTime不能为空")
    @ApiModelProperty("开始学习时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;

    @NotNull(message = "提交时间commitTime不能为空")
    @ApiModelProperty("提交时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime commitTime;

    @Override
    public String toString() {
        return "{" +
                "\"trainingId\":" + trainingId +
                ",\"startTime\":" + startTime +
                ",\"commitTime\":" + commitTime +
                "}";
    }
}
